package hook;

import java.sql.SQLOutput;
import java.util.concurrent.TimeUnit;

public class Lesson1 {

    public static void main(String[] args) {

        Runtime.getRuntime().addShutdownHook(new Thread(() ->{
            System.out.println("shutdownHook execute start ...");
            try {
                TimeUnit.SECONDS.sleep(3);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println("shutdownHook execute end ...");
        }));

        try {
            TimeUnit.SECONDS.sleep(7);
            System.exit(0);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
